<template>
  <div class="role">
    <PageSearch :fromConfig="fromConfig" />
    <div class="content">
      <PageContent
        :contentTableConfig="contentTableConfig"
        pageName="role"
        @newBtnClick="newBtnClick"
        @editBtnClick="editBtnClick"
      />
    </div>

    <PageModal
      pageName="role"
      :Modalconfig="Modalconfig"
      ref="pageModalRef"
      :defaultInfo="defaultInfo"
    >
      <el-tree
        :data="roles"
        :props="{ children: 'children', label: 'name' }"
        show-checkbox
        node-key="id"
        lazy="true"
        class="el-tree"
      />
    </PageModal>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from "vue";
import { useStore } from "vuex";
import PageSearch from "@/components/page-search";
import PageContent from "@/components/page-content/index";
import { contentTableConfig } from "./config/content.config";
import { fromConfig } from "./config/user.config";
import { Modalconfig } from "./config/modal.config";
import PageModal from "@/components/page-modal";
import { userModal } from "@/hooks/userModal";

export default defineComponent({
  name: "role",
  components: {
    PageContent,
    PageSearch,
    PageModal,
  },
  setup() {
    const [pageModalRef, defaultInfo, newBtnClick, editBtnClick] = userModal();
    const store = useStore();
    const roles = computed(() => store.state.entirRole);

    return {
      contentTableConfig,
      fromConfig,
      Modalconfig,
      pageModalRef,
      defaultInfo,
      newBtnClick,
      editBtnClick,
      roles,
    };
  },
});
</script>

<style scoped lang="less">
.content {
  padding: 20px 60px;
  background-color: #fff;
  margin-top: 20px;
  .user-con-header {
    text-align: left;
    padding: 0px 10px 10px 0;
  }
}
.el-tree {
  text-align: center;
  margin-left: 75px;
}
</style>
